// pages/main/invoiceMsg/invoiceMsg.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    invoice:[
      { company: '享多多互联网技术有限公司', invoiceNum: '656656565dd5asd8ads', invoiceType: 0,choiseIcon:1},
      { company: '科脉技术有限公司', invoiceNum: '656656sdfsddd5asd8ads', invoiceType: 1, choiseIcon:0 },
      { company: '享多多互联网技术有限公司', invoiceNum: '656656565dd5asd8ads', invoiceType: 0, choiseIcon:0 }
    ],
    invoiceNeed:0
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  // 新增发票按钮
  addInvoice:function(){
    wx.navigateTo({
      url: '../addinvoice/addinvoice',
    })
  },
  //点击编辑发票信息
  editInvoice: function (e) {
    wx.navigateTo({
      url: '../addinvoice/addinvoice',
    })
  },
  // 点击选中发票
  checkboxChange:function(e){
    var val = e.detail.value[0];
    var invoiceList = this.data.invoice;
    if (val == 0){
      for (var i = 0; i < invoiceList.length; i++) {
        invoiceList[i].choiseIcon = 0;
      }
      this.setData({
        invoice: invoiceList
      })
    }
    console.log(val)
  },
  choiseInvoice: function (e) {
    var dis = e.currentTarget.dataset.dis;
    var invoiceList = this.data.invoice;
    for (var i = 0; i < invoiceList.length; i++) {
      invoiceList[i].choiseIcon = 0;
    }
    invoiceList[dis].choiseIcon = 1;
    this.setData({
      invoice: invoiceList,
      invoiceNeed: undefined
    })
    wx.navigateBack({
      delta: 1
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})